package com.tnl.app.dao;

import com.biz.hunter.db.entity.OrderSalary;
import com.biz.hunter.dbutil.BaseDAO;
import org.springframework.stereotype.Repository;

@Repository
public class OrderSalaryDAO {
	private static final String SQL_GET_ID = "select * from tb_order_salary where id = ?";
	private static final String SQL_SAVE = "INSERT INTO tb_order_salary(openid, orderId,employeeId,hunterId,ordescId,"
			+ "monthlypay,month,salary,reward,"
			+ "remark,createtime,updatetime) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
	private static final String SQL_GET_ORDERID="select * from tb_order_salary where orderId=?";
	private static final String SQL_COUNT_BY_ORDERID = "select count(1) from tb_order_salary where orderId=?";
	
	public OrderSalary getById(long Id) {
		return BaseDAO.queryForObject(OrderSalary.class, SQL_GET_ID, Id);
	}

	public OrderSalary getByOrderId(long orderId){
		return BaseDAO.queryForObject(OrderSalary.class, SQL_GET_ORDERID, orderId);
	}
	
	public long saveOrderSalary(OrderSalary salary) {
		if (salary == null) {
			return -1;
		}

		Long result = BaseDAO.save(SQL_SAVE, salary.getOpenid(), salary.getOrderId(),
				salary.getEmployeeId(),salary.getHunterId(),salary.getOrdescId(),
				salary.getMonthlypay(),salary.getMonth(),salary.getSalary(),salary.getReward(),
				salary.getRemark(),salary.getCreatetime(),salary.getUpdatetime());
		if (result != null) {
			return result.longValue();
		}
		return -1;
	}
//	public long countByOrderId(Long orderId) {
//
//
//		Long result = BaseDAO.q(SQL_COUNT_BY_ORDERID, salary.getOpenid(), salary.getOrderId(),
//				salary.getEmployeeId(),salary.getHunterId(),salary.getOrdescId(),
//				salary.getMonthlypay(),salary.getMonth(),salary.getSalary(),salary.getReward(),
//				salary.getRemark(),salary.getCreatetime(),salary.getUpdatetime());
//		if (result != null) {
//			return result.longValue();
//		}
//		return -1;
//	}

	


}
